package 周赛;

public class Bank {
    long[] bank;
    int len;
    public Bank(long[] balance) {
        bank = balance;
        len = balance.length;
    }
    //转账 1 向 2 转账
    public boolean transfer(int account1, int account2, long money) {
        if (account1>len || account2>len)
            return false;
        if (bank[account1-1]<money){
            return false;
        }
        bank[account1-1]-=money;
        bank[account2-1]+=money;
        return true;
    }
    //存款
    public boolean deposit(int account, long money) {
        if (account>len)
            return false;
        bank[account-1]+=money;
        return true;
    }
    //取款
    public boolean withdraw(int account, long money) {
         if (account>len)
             return false;
         if (bank[account-1]<money)
             return false;
         bank[account-1]-=money;
         return true;
    }
}
